import ctypes
handles=[]
def findGameWindowHandle(hwnd,lParam):
    gameTitle = b"SCIONS_OF_FATE_CLIENT"
    
    byteListp = ctypes.c_char_p()
    byteListp.value = b'\x00'*50
    ctypes.windll.user32.GetWindowTextA(hwnd,byteListp,50)
    # print("byteListp的指向的值",byteListp.value)
    if byteListp.value == gameTitle:
        handles.append(hwnd)
    return True

def getGameWindowHandles():
    FUC = ctypes.WINFUNCTYPE(ctypes.c_bool,ctypes.c_int,ctypes.c_int)
    cmp_func = FUC(findGameWindowHandle)
    enumSuccessFlag = ctypes.windll.user32.EnumWindows(cmp_func,0)
    if enumSuccessFlag == 0:
        print("EnumWindows执行失败")
    return handles

